import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop029_新增普通商品标签"
name='华为手机，华为耳机'

# 后台登录，商品管理,商品标签,商品标签分组
dr=openBrowser(urlAdmin)
DBshopLoginAdmin(dr)
DBshopEnterMenu3(dr,"商品管理","商品标签","普通商品标签")

# 1.点击“添加普通商品标签”。
dr.find_element_by_partial_link_text("添加普通商品标签").click()
time.sleep(2)

# 2.填写标签分组“华为老大”，标签名称“华为手机，华为耳机”，标签排序255
dr.find_element_by_xpath('//option[text()="华为老大"]').click()
time.sleep(2)
dr.find_element_by_id('tag_name').send_keys(name)
dr.find_element_by_id('tag_sort').clear()
dr.find_element_by_id('tag_sort').send_keys('255')

# 3.点击“保存标签信息”，保存成功
dr.find_element_by_xpath("//button").click()
time.sleep(2)

#获取页面中的文本
a=dr.find_element_by_xpath("//body").text
# print(a)
b=' '
c=' 华为老大'
sj=reGetString(a,b,c)
print(sj)

#断言
if sj==name:
    writeLog('%s 测试通过'% testCase)
else:
    writeLog('%s 测试不通过'% testCase)
    getPhoto(dr)
dr.quit()